import gnupg

from drek.config import get_gpg_home  # type: ignore
from drek.utils.environ import get_home_dir  # type: ignore


def get_gpg_home_path():
    return f"{get_home_dir()}/{get_gpg_home()}"


def list_keys(gpg_home=get_gpg_home_path(), secret=False):
    print("List keys...")
    gpg = gnupg.GPG(gnupghome=gpg_home)
    keys = gpg.list_keys(secret)
    for key in keys:
        print(f'{key.get("keyid", "miss")} - {key.get("uids", "miss")}')
        print("")
